Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lodash.defaults

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.defaults

The lodash method `_.defaults` exported as a module.

  • 4.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12M
increased by3.16%
Maintainers
3
Weekly downloads
 
Created

What is lodash.defaults?

The lodash.defaults npm package is a utility that allows for the assignment of default values to properties in an object. It is particularly useful when you want to ensure that an object contains certain properties with default values if those properties are not already defined. This can be very handy in configuration objects, options for functions, or any scenario where you want to merge an object with a set of defaults.

What are lodash.defaults's main functionalities?

Assigning default values to an object

This feature allows you to assign default values from the source object to the destination object for all properties that are undefined in the destination object. In the code sample, the result will have the properties of the object with 'a' remaining as 1 (since it's already defined) and 'b' being set to 2 from the source object since 'b' is not defined in the destination object.

{"const defaults = require('lodash.defaults');\nconst object = { 'a': 1 };\nconst source = { 'a': 3, 'b': 2 };\nconst result = defaults(object, source);\nconsole.log(result); // => { 'a': 1, 'b': 2 }"}

Other packages similar to lodash.defaults

Keywords

FAQs

Package last updated on 13 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc